package org.wlw.servlet;

import org.wlw.models.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/users")
public class UserListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<User> users = new ArrayList<>();
        users.add(new User("admin","123","管理员"));
        users.add(new User("zhangsan","222","张三"));
        users.add(new User("lisi","1223","李四"));
        users.add(new User("wangwu","3212","王五"));
        users.add(new User("zhaoliu","2112","赵六"));
        req.setAttribute("users",users);
        req.getRequestDispatcher("/WEB-INF/jsp/users.jsp").forward(req,resp);
    }
}
